<template>
    <div class="app" v-if="!counter.los">
        <div class="nav">
            <Navict></Navict>
        </div>
        <div class="mid">
            <el-card class="head">
                <div class="title">
                    <span style="font-size: 30px;">{{ counter.infos.jobname }}</span>
                    <span style="font-size: 25px;margin-left: 20px;color:red">{{ counter.infos.price }}</span>
                    <br>
                    <span >
                        {{ counter.infos.experience }}
                    </span>
                </div>
                <div class="tag">
                    <div class="tags" v-for="(item,index) in counter.infos.tags" :key="index">
                        {{ item }}
                    </div>
                </div>
                <div class="ltd">
                    {{ counter.infos.ltd }}
                </div>
            </el-card>
        </div>
        <el-card class="body">
            <div class="title-b">
                岗位描述
            </div>
            <div class="text">
                {{ counter.infos.descriptions  }}
            </div>
            <div class="title-b" >
                工作地址
            </div>
            <div class="text">
                {{ counter.infos.address }}
            </div>
        </el-card>
        <div style="margin-top: 20px;">
            <BottomNavict></BottomNavict>
        </div>
    </div>
    <div class="los" v-else>
        <div class="img">
            你来到了无人区！！
        </div>
    </div>
</template>

<script setup>
import Navict from './Navict.vue'
import BottomNavict from './BottomNavict.vue'
import { useCounterStore } from "../stores/counter"
import { onMounted } from 'vue'
import axios from 'axios'
import { useRoute,useRouter } from "vue-router";
import { ElMessage } from 'element-plus'

const route = useRoute();
const router = useRouter();
const counter = useCounterStore()

function getJobInfo() {
    if (route.query.id) {
        axios.get(`http://localhost:8080/jobs/links`,{params: {info_id: route.query.id}}).then((res) => {
           if(res.data.code === 200){
                console.log(res.data)
                counter.get_info(res.data.result)
                counter.set_los(false)
           }else{
                ElMessage.error(res.data.result)
                counter.set_los(true)
           }
        })
    }
}

onMounted(() => {
    getJobInfo()
})
</script>

<style scoped>
    .app{
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;    
    }
    .mid{
        width: 80%;
        height: auto;
        margin: 0 auto;
        margin-top: 20px;
        margin-bottom: 20px;
        display: flex;
        justify-content: center;
    }
    .head{
        width: 90%;
        height: auto;
        border-radius: 8px;
        margin: 20px 0;
    }
    .title{
        width: 50%;
        line-height: 50px;
        text-align: left;
        font-size: 20px;
        font-weight: 600;
        color: #333;
    }
    .tag{
        width: 70%;
        display: flex;
        justify-content: space-evenly;
        margin-bottom: 40px;
    }
    .tags{
        font-size: 15px;
        color: #676767;
        width: calc(25%);
        text-align: center;
        height: auto;
        border-radius: 3px;
        border:solid 1px #aeadad;
    }
    .ltd{
        width: 20%;
        line-height: 50px;
        font-size: 20px;
        font-weight: 600;
        color: #333;
    }
    .body{
        width: 72%;
        height: auto;
        margin: 0 auto;
    }
    .title-b{
        width: 90%;
        font-size: 20px;
        font-weight: 600;
        color: #333;
        margin-top: 20px;
        margin-bottom: 20px;
    }
    .los{
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .img{
        width: 800px;
        height: 600px;
        margin: 0 auto;
        background-image: url(../static/404.png);
        background-size: 100% 100%;
        text-align: center;
        font-size: 40px;
        letter-spacing: 6px;
        font-weight: 600;
        text-transform: uppercase;
        color: #70b6fe;
    }
</style>